using Unity.VisualScripting;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Load DataTable")]
    [UnitSurtitle("Failure")]
    public sealed class LoadDataTableFailure : FrameworkEventUnit<LoadDataTableFailureEventArgs>
    {
        protected override int EventId => LoadDataTableFailureEventArgs.EventId;
        protected override string HookName => UGFHookNames.LoadDataTableFailure;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DataTableAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput ErrorMessage
        {
            get;
            private set;
        }
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            DataTableAssetName = ValueOutput<string>(nameof(DataTableAssetName));
            ErrorMessage = ValueOutput<string>(nameof(ErrorMessage));
            UserData = ValueOutput<object>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, LoadDataTableFailureEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(DataTableAssetName, args.DataTableAssetName);
            flow.SetValue(ErrorMessage, args.ErrorMessage);
            flow.SetValue(UserData, args.UserData);
        }
    }
}